window = globalThis;
// ---------------------------------
innerWidth = outerWidth = 1536;
outerHeight = 834
innerHeight = clientHeight = 747

// ---------------------------------
meta = [
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return null}
            if (arg === 'content') {return null}
        },
    },
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return 'keywords'}
            if (arg === 'content') {return '智能无感验证,验证码,滑动拼图验证码,滑块验证码,行为验证码'}
        },
    },
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return 'description'}
            if (arg === 'content') {return '顶象验证码,以设备环境､行为特征等多风险判断要素,通过智能无感验证､滑动拼图验证等13种验证方式,帮助客户进行人机风险防控,阻挡机器风险行为.免费体验!'}
        },
    },
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return 'viewport'}
            if (arg === 'content') {return 'width=1280,initial-scale=0.2'}
        },
    },
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return 'format-detection'}
            if (arg === 'content') {return 'telephone=no,address=no,email=no'}
        },

    },
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return 'apple-mobile-web-app-capable'}
            if (arg === 'content') {return 'yes'}
        },
    },
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return 'apple-mobile-web-app-status-bar-style'}
            if (arg === 'content') {return 'black'}
        },

    },
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return null}
            if (arg === 'content') {return 'IE=edge,chrome=1'}
        },

    },
    {
        getAttribute: function (arg) {
            console.log('方法:', 'documentElement-getAttribute', '参数:', arg)
            if (arg === 'name') {return 'renderer'}
            if (arg === 'content') {return 'webkit'}
        },

    }
]

location = {
    "ancestorOrigins": {},
    "href": "https://www.dingxiang-inc.com/business/captcha",
    "origin": "https://www.dingxiang-inc.com",
    "protocol": "https:",
    "host": "www.dingxiang-inc.com",
    "hostname": "www.dingxiang-inc.com",
    "port": "",
    "pathname": "/business/captcha",
    "search": "",
    "hash": ""
}
// ---------------------------------
navigator = {
    appCodeName: "Mozilla",
    appName: "Netscape",
    appVersion: "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
    userAgent: '"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"\n',
    vendor: "Google Inc.",
    vendorSub: "",
    product: "Gecko",
    cookieEnabled: true,
    pdfViewerEnabled: true,
    productSub: "20030107",
    webdriver: false,
    platform: 'Win32',
    language: 'zh-CN',
    languages: ['zh-CN']
}

// ---------------------------------
var iframe = {
    sandbox: '',
    style: {display: ''},
    contentWindow: window,
}
var innerText = '<div class="wrapper-main"><div class="wrapper wrapper-header"><div class="container"><h1 class="logo loaded" data-role="lazyload"><a href="/" title="顶象">顶象</a></h1><ul class="na';

var randomsNum = Math.floor((Math.random() * (136741 / 3 - 136541 / 3)) + 136541 / 3)
document = {
    "title": '顶象验证码 - 智能无感验证_滑动拼图验证｢免费体验｣',
    'body': {
        'scrollTop': 4000,
        "scrollLeft": 0,
        'innerHTML': innerText + 'div'.repeat(randomsNum),
        'clientWidth': 1519,
        'clientHeight': clientHeight,
        'appendChild': function () {
            console.log('document.body.appendChild >> ', arguments);
        },
        'removeChild': function () {
            // console.log('document.body.removeChild >> ', arguments);
        }
    },
    'createElement': function (x) {
        console.log('document.createElement >> ', arguments);
        if (x == 'iframe') {
            return iframe
        }
    },
    "removeEventListener": function () {
        console.log('removeEventListener >', arguments)
    },
    "addEventListener": function () {
        console.log('addEventListener >', arguments)
    },
    "readyState": 'complete',
    "referrer": "",
    "documentElement": {
        'scrollTop': 0,
        "scrollLeft": 0,
        "clientWidth ": innerWidth,
        "clientHeight": clientHeight,
        "doScroll": undefined,
        "getAttribute": function (arg) {
            return null
        }
    },
    "getElementsByTagName": function (arg) {
        console.log('document.getElementsByTagName', arg)
        if (arguments[0] === 'meta') {
            return meta;
        } else if (arguments[0] == 'head') {
            return [
                {"innerHTML": {length: randomsNum + Math.floor(Math.random() * (18252 - 18052)) + 18052}}
            ]
            return {}
        }
    }
}

// ---------------------------------
let Screen = function () {
}
Screen.prototype.width = innerWidth;
Screen.prototype.height = 864;
Screen.prototype.availWidth = innerWidth;
Screen.prototype.availHeight = outerHeight;
Screen.prototype.colorDepth = 24;
Screen.prototype.availLeft = 0;
Screen.prototype.availTop = 0;
Screen.prototype.isExtended = false;
Screen.prototype.onchange = null;
Screen.prototype.pixelDepth = 24;
Screen.prototype.orientation = new (class ScreenOrientation {
})
window.screen = new Screen();
// ---------------------------------


require('./greenseer');
// with (window) {
/*! greenseer 2024-02-23 19:00:02 de473df7edc6fd308535086a326f6b091d9dab2f */

// }

function slide_track(distance) {
    /**生成轨迹*/
    function __ease_out_expo(sep) {
        if (sep == 1) {
            return 1
        } else {
            return 1 - Math.pow(2, -10 * sep)
        }
    }

    function random_randint(min, max) {
        var range = max - min;
        var rand = Math.random();
        var num = min + Math.round(rand * range);
        return num;
    }

    var slide_track = [
        [616, 299, 3515] // [616,299]
    ]
    var count = 30 + parseInt(distance / 2)
    var t = random_randint(50, 100)
    var _x = 0,
        _y = 0
    for (i = 0; i < count; i++) {
        var x = Math.round(__ease_out_expo(i / count) * distance)
        var t = t + random_randint(30, 50)
        if (x == _x) {
            continue
        }
        slide_track.push([372 + x, 507 + _y, 3515 + t])
        _x = x
    }
    return slide_track
}

//_init.__proto__即window.dc
function slide_ac(sid, xdistance, ydistance) {
    /**
     * 生成ac参数
     */
    debugger;
    // var mousemove = []
    var mousemove = slide_track(xdistance);  // 生成轨迹
    // console.log(mousemove)
    _init = window._dx['UA']['init']({})
    _init.__proto__.ua = ""  // ua置空，重新生成
    _init.__proto__._ua = ""
    _init.__proto__.option = {
        "token": sid, //图片token
        "form": ""
    }
    _init.__proto__.getTK() // token校验
    _init.__proto__._sa = []
    for (i = 0; i < mousemove.length; i++) {
        _init.__proto__.tm = new Date().getTime() - mousemove[i][2]
        _init.__proto__.recordSA({"pageX": mousemove[i][0], "pageY": mousemove[i][1]})
    }
    _init.__proto__.sendSA() //  对recordSA处理后的移动轨迹进行加密，然后更新ua的值。
    //return _init.__proto__.ua
    // 对缺口位置、滑块dom信息进行处理，再次更新ua的值，就是最终的ac参数，即getUA()的返回值。
    _init.__proto__.sendTemp({    //
        "xpath": "/html/body/div[10]",
        "x": xdistance, //移动距离
        "y": ydistance //  a响应返回的y
    })
    return _init.__proto__.ua
}

// 4086#m8XEbbHcdsEv0bp7dKH85bsz9pDW74Hy9KFa5f6t9UdkGbBSE8rXUy7eRP3qDmIn/PWYRcuEW/gLsV3FTrbdu28PnwgfIhuTPyQTF35d8z2UuDboR/aJm1ni8u3dW89AHVr=
// var r = slide_ac("29d16dbf873151399233464d7f96407a", 172, 51)
// console.log(r, ' >> ', r.length);





